package com.ufgov.ip.dao;

import java.util.List;

import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.data.repository.query.Param;

import com.ufgov.ip.entity.IpHirer;

public interface IuapHirerDao extends PagingAndSortingRepository<IpHirer, String>,JpaSpecificationExecutor<IpHirer> {
	
	IpHirer findByHirerName(String hirerName);

	IpHirer findHirerByCellphoneNo(String cellphoneNo);

	IpHirer findHirerByEmail(String email);
	
	@Query("from IpHirer ih where email=:loginName or loginName=:loginName or cellphoneNo=:loginName")
	IpHirer findHirerByEmailOrLoginNameOrCellphoneNo(@Param("loginName")String loginName);

	@Query("from IpHirer ih where password=:password")
	IpHirer findHirerByPassword(@Param("password")String password);
	
	@Query("from IpHirer ih where hirerId=:hirerId")
	IpHirer findHirerByHirerId(@Param("hirerId")String hirerId);
	
	@Modifying(clearAutomatically = true) @Query("update IpHirer ipHirer set ipHirer.hirerLogoUrl=:hirerLogoUrl where ipHirer.hirerId=:hirerId")
	 void updateHirerByHirerId(@Param("hirerId")String hirerId, @Param("hirerLogoUrl")String hirerLogoUrl);

	@Query(" from IpHirer order by hirerNo asc")
	List<IpHirer> findHirerAll();
	
}
